From b73d291086aea251c48d21192e1818488a1b58f4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 17 Jan 2014 19:43:22 -0500 Subject: [PATCH] header bar: Make it possible to have no title Add a custom title had the side-effect of showing the widget. That is not right, adding children and managing their visibility should be independent. The headerbar size allocation code also made the assumption that a custom title is always visible. With these changes, GtkHeaderBar should be usable in situations where the centering functionality is not required, and it is important to freely pack content at both ends, such as in nautilus. https://bugzilla.gnome.org/show_bug.cgi?id=722340 --- gtk/gtkheaderbar.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c index 8fedcbad12..29e6d2695e 100644 --- a/gtk/gtkheaderbar.c +++ b/gtk/gtkheaderbar.c @@ -730,8 +730,7 @@ gtk_header_bar_compute_size_for_orientation (GtkWidget *widget, } } - if (priv->label_box != NULL && - gtk_widget_get_visible (priv->label_box)) + if (priv->label_box != NULL) { gtk_widget_get_preferred_width (priv->label_sizing_box, &child_size, &child_natural); @@ -865,8 +864,7 @@ gtk_header_bar_compute_size_for_opposing_orientation (GtkWidget *widget, i += 1; } - if (priv->label_box != NULL && - gtk_widget_get_visible (priv->label_box)) + if (priv->label_box != NULL) { gtk_widget_get_preferred_height (priv->label_sizing_box, &child_minimum, &child_natural); @@ -993,14 +991,16 @@ gtk_header_bar_size_allocate (GtkWidget *widget, i++; } - if (priv->custom_title) + if (priv->custom_title && + gtk_widget_get_visible (priv->custom_title)) { gtk_widget_get_preferred_width_for_height (priv->custom_title, height, &title_minimum_size, &title_natural_size); } - else + + if (priv->label_box != NULL) { gtk_widget_get_preferred_width_for_height (priv->label_box, height, @@ -1108,9 +1108,11 @@ gtk_header_bar_size_allocate (GtkWidget *widget, if (direction == GTK_TEXT_DIR_RTL) child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; - if (priv->custom_title) + if (priv->custom_title != NULL && + gtk_widget_get_visible (priv->custom_title)) gtk_widget_size_allocate (priv->custom_title, &child_allocation); - else + + if (priv->label_box != NULL) gtk_widget_size_allocate (priv->label_box, &child_allocation); if (priv->titlebar_start_box) @@ -1298,7 +1300,6 @@ gtk_header_bar_set_custom_title (GtkHeaderBar *bar, gtk_widget_set_parent (priv->custom_title, GTK_WIDGET (bar)); gtk_widget_set_valign (priv->custom_title, GTK_ALIGN_CENTER); - gtk_widget_show (title_widget); if (priv->label_box != NULL) { -- 2.30.2